package com.masterrabbit.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.masterrabbit.common.log.annotation.Log;
import com.masterrabbit.common.log.enums.BusinessType;
import com.masterrabbit.common.security.annotation.RequiresPermissions;
import com.masterrabbit.domain.EmergencyRescueRecords;
import com.masterrabbit.service.IEmergencyRescueRecordsService;
import com.masterrabbit.common.core.web.controller.BaseController;
import com.masterrabbit.common.core.web.domain.AjaxResult;
import com.masterrabbit.common.core.utils.poi.ExcelUtil;
import com.masterrabbit.common.core.web.page.TableDataInfo;

/**
 * 应急救援记录Controller
 * 
 * @author laotu
 * @date 2025-03-19
 */
@RestController
@RequestMapping("/emergencyrescuerecords")
public class EmergencyRescueRecordsController extends BaseController
{
    @Autowired
    private IEmergencyRescueRecordsService emergencyRescueRecordsService;

    /**
     * 查询应急救援记录列表
     */
    @RequiresPermissions("masterrabbit-kaixuan:emergencyrescuerecords:list")
    @GetMapping("/list")
    public TableDataInfo list(EmergencyRescueRecords emergencyRescueRecords)
    {
        startPage();
        List<EmergencyRescueRecords> list = emergencyRescueRecordsService.selectEmergencyRescueRecordsList(emergencyRescueRecords);
        return getDataTable(list);
    }

    /**
     * 导出应急救援记录列表
     */
    @RequiresPermissions("masterrabbit-kaixuan:emergencyrescuerecords:export")
    @Log(title = "应急救援记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EmergencyRescueRecords emergencyRescueRecords)
    {
        List<EmergencyRescueRecords> list = emergencyRescueRecordsService.selectEmergencyRescueRecordsList(emergencyRescueRecords);
        ExcelUtil<EmergencyRescueRecords> util = new ExcelUtil<EmergencyRescueRecords>(EmergencyRescueRecords.class);
        util.exportExcel(response, list, "应急救援记录数据");
    }

    /**
     * 获取应急救援记录详细信息
     */
    @RequiresPermissions("masterrabbit-kaixuan:emergencyrescuerecords:query")
    @GetMapping(value = "/{rescueId}")
    public AjaxResult getInfo(@PathVariable("rescueId") Long rescueId)
    {
        return success(emergencyRescueRecordsService.selectEmergencyRescueRecordsByRescueId(rescueId));
    }

    /**
     * 新增应急救援记录
     */
    @RequiresPermissions("masterrabbit-kaixuan:emergencyrescuerecords:add")
    @Log(title = "应急救援记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EmergencyRescueRecords emergencyRescueRecords)
    {
        return toAjax(emergencyRescueRecordsService.insertEmergencyRescueRecords(emergencyRescueRecords));
    }

    /**
     * 修改应急救援记录
     */
    @RequiresPermissions("masterrabbit-kaixuan:emergencyrescuerecords:edit")
    @Log(title = "应急救援记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EmergencyRescueRecords emergencyRescueRecords)
    {
        return toAjax(emergencyRescueRecordsService.updateEmergencyRescueRecords(emergencyRescueRecords));
    }

    /**
     * 删除应急救援记录
     */
    @RequiresPermissions("masterrabbit-kaixuan:emergencyrescuerecords:remove")
    @Log(title = "应急救援记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{rescueIds}")
    public AjaxResult remove(@PathVariable Long[] rescueIds)
    {
        return toAjax(emergencyRescueRecordsService.deleteEmergencyRescueRecordsByRescueIds(rescueIds));
    }
}
